# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: donggu

from experimental.prophet.contrib.variable import last_valid
from experimental.prophet.ops.elemwise_math import sign
from experimental.prophet.ops import timeseries


# $TICK
# num of upticks - num of downticks
# tick([coin1.trade.price, coin2.trade.price])
def tick(trade_prices):
  sum = 0
  for p in trade_prices:
    p = last_valid(p)
    sum += sign(p - timeseries.shift(p, 1))

  return sum


__all__ = ['tick']
